import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("charging_station", { schema: "charge" })
export class ChargingStation {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", { name: "name", length: 100 })
  name: string;

  @Column("int", {
    name: "owner",
    comment: "归属",
    unsigned: true,
    default: () => "'0'",
  })
  owner: number;

  @Column("int", {
    name: "creator_id",
    comment: "创建人",
    unsigned: true,
    default: () => "'0'",
  })
  creatorId: number;

  @Column("varchar", { name: "leader", length: 10 })
  leader: string;

  @Column("varchar", { name: "tel", length: 11 })
  tel: string;

  @Column("double", {
    name: "longitude",
    nullable: true,
    comment: "经度",
    precision: 22,
  })
  longitude: number | null;

  @Column("double", {
    name: "latitude",
    nullable: true,
    comment: "维度",
    precision: 22,
  })
  latitude: number | null;

  @Column("varchar", { name: "address", comment: "地址", length: 100 })
  address: string;

  @Column("int", {
    name: "slow_pricing",
    comment: "慢充收费",
    unsigned: true,
    default: () => "'0'",
  })
  slowPricing: number;

  @Column("int", {
    name: "fast_pricing",
    comment: "快充收费",
    unsigned: true,
    default: () => "'0'",
  })
  fastPricing: number;

  @Column("json", { name: "devices", nullable: true, comment: "设备" })
  devices: object | null;

  @Column("json", { name: "pics", nullable: true, comment: "图片" })
  pics: string[] | null;

  @Column("json", { name: "labels", nullable: true, comment: "标签" })
  labels: string[] | null;

  @Column("text", { name: "desc", nullable: true, comment: "描述" })
  desc: string | null;

  @Column("int", {
    name: "total_charge_order_count",
    comment: "总充电订单数",
    unsigned: true,
    default: () => "'0'",
  })
  totalChargeOrderCount: number;

  @Column("decimal", {
    name: "total_charge_amount",
    comment: "总收入",
    precision: 12,
    scale: 2,
    default: () => "'0.00'",
  })
  totalChargeAmount: string;

  @Column("float", {
    name: "total_charge_kwh",
    unsigned: true,
    precision: 15,
    scale: 5,
    default: () => "'0.00000'",
  })
  totalChargeKwh: number;

  @Column("int", {
    name: "total_charge_time",
    comment: "总充电时长，秒",
    unsigned: true,
    default: () => "'0'",
  })
  totalChargeTime: number;

  @Column("int", { name: "create_time", unsigned: true, default: () => "'0'" })
  createTime: number;
}
